package com.li.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.li.DTO.AreaManageDTO;
import com.li.VO.PageListVO;
import com.li.mapper.SubregionManageMapper;
import com.li.pojo.AreaManage;
import com.li.service.SubregionManageService;
import com.li.util.BeanContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: zhiqingLi
 * @Description:
 * @Date: Created in 13:48 2024/3/13
 **/
@Service
public class SubregionManageServiceImpl implements SubregionManageService {

    @Autowired
    private SubregionManageMapper subregionManageMapper;

    @Override
    public PageListVO showList(AreaManageDTO areaManageDTO) {
        PageHelper.startPage(areaManageDTO.getPageIndex(),areaManageDTO.getPageSize());
        Page<AreaManage> page = subregionManageMapper.showList(areaManageDTO.getName(), BeanContent.getCurrentId());
        return new PageListVO(page.getTotal(),page.getResult());
    }

    @Override
    public void addSubregion(AreaManage areaManage) {
        areaManage.setCompanyId(BeanContent.getCurrentId());
        areaManage.setIsf(0);
        System.out.println(areaManage);
        subregionManageMapper.addSubregion(areaManage);
    }

    @Override
    public AreaManage updGetById(Long id) {
        return subregionManageMapper.updGetById(id);
    }

    @Override
    public void updSubregion(AreaManage areaManage) {
        subregionManageMapper.updSubregion(areaManage);
    }

    @Override
    public void delById(Long id) {
        subregionManageMapper.delById(id);
    }
}
